package com.chzsyh.evwer.ui

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.chzsyh.evwer.FullScreenDialog
import com.chzsyh.evwer.R
import com.chzsyh.evwer.databinding.ActivityMainBinding
import com.chzsyh.evwer.ui.activity.WebSocketActivity
import com.modxiageasyh.constraintlayoutldemo.ConstraintLayoutActivity
import com.modxiageasyh.coroutinedemolibrary.CoroutinesActivity
import com.modxiageasyh.mixinglibrary.MxMainActivity
import com.owbtgad.common.base.BaseDActivity
import com.owbtgad.common.utils.ARouterString
import com.owbtgad.common.utils.AppCache
import com.owbtgad.common.utils.MyUtils
import com.shuyihui.animdemo.AminActivity
import com.shuyihui.identity.CertificationActivity


@Route(path = ARouterString.MAIN_ACTIVITY)
class MainActivity : BaseDActivity<ActivityMainBinding>() {
    override fun getContentLayout(): Int {
        return R.layout.activity_main
    }

    override fun initView(savedInstanceState: Bundle?) {
        val context: Context = this
        AppCache.setAccessToken("962z7UbKl/mPeeTxs/AXtY0NL6A1YFDdXWb1IGvnVeZDtNS2prDjA0toXGd6eW+fva/4DMEj5kE0k/GKOg7p5Q==")
        mBinding.btnConstraintLayout.also {
            MyUtils.viewClicks(it) {
                val view: View =
                    LayoutInflater.from(context).inflate(R.layout.dialog_face_check, null)
                view.alpha = 0.3f
                val dialog: Dialog = FullScreenDialog(
                    context,
                    android.R.style.Theme_DeviceDefault_Light_NoActionBar, view
                )
                view.setOnTouchListener { v, event -> false }
                dialog.setCancelable(true)
                dialog.setOnCancelListener { }
                dialog.show()
                /*dialog.setOnDismissListener {

                    startActivity(Intent(this, ConstraintLayoutActivity::class.java))
                }*/
            }
        }
        mBinding.btnCoroutineActivity.also {
            MyUtils.viewClicks(it) {
                startActivity(Intent(this, CoroutinesActivity::class.java))
            }
        }
        mBinding.btnMixinglibrary.also {
            MyUtils.viewClicks(it) {
                startActivity(Intent(this, MxMainActivity::class.java))
            }
        }
        mBinding.btnCertificationActivity.also {
            MyUtils.viewClicks(it) {
                CertificationActivity.start(mContext!!)
            }
        }
        mBinding.anim.also {
            MyUtils.viewClicks(it) {
                startActivity(Intent(this, AminActivity::class.java))
            }

        }
        mBinding.webSocket.apply {
            MyUtils.viewClicks(this) {
                WebSocketActivity.start(mContext)
            }
        }

//        ApkTool.getPackages(this)
        val a = string.toInt()

        if (a > 20) {
            Log.d(TAG, "initView: " + a % 2)
        }
    }

    val string = "222"

    val s =
        "https://play.google.com/store/apps/details?id=com.guoyu.zidiancn&referrer=adjust_reftag=cpDrwkjlXt5lT&utm_source=cashya"
    val a = "https://play.google.com/store/apps/details?id=com.guoyu.gushicicn&referrer=ccc"
    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)

    }


}